package blogs.eidos.cloud.framework.common.entity;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * @author ： Eidos
 * @date ：Created in 2021-02-01
 * @description：实体操作人记录 实体类
 * @modified By：
 * @version: 1.0
 */
@Data
public class RecordInfo<T> extends BaseEntity {

    @ApiModelProperty(value = "创建人ID")
    @JSONField(serialize = false)
    Long createId;

    @ApiModelProperty(value = "创建人名称")
    @JSONField(serialize = false)
    String createName;

    @ApiModelProperty(value = "创建时间")
    @JSONField(serialize = false)
    Date createTime;

    @ApiModelProperty(value = "修改人ID")
    @JSONField(serialize = false)
    Long updateId;

    @ApiModelProperty(value = "修改人名称")
    @JSONField(serialize = false)
    String updateName;

    @ApiModelProperty(value = "修改时间")
    @JSONField(serialize = false)
    Date updateTime;

    public T createdByPo(Long userId, String userName) {
        Date now = new Date();
        this.createId = userId;
        this.createName = userName;
        this.createTime = now;
        this.updateId = userId;
        this.updateName = userName;
        this.updateTime = now;
        return (T) this;
    }

    public T updatedByPo(Long userId, String userName) {
        this.updateId = userId;
        this.updateName = userName;
        this.updateTime = new Date();
        return (T) this;
    }
}
